package com.free.front.controller.product;

import javax.servlet.http.HttpServletRequest;

import com.deco.domain.vo.product.PartsCategoryVo;
import com.deco.domain.vo.product.PartsInfoVedioVo;
import com.free.common.vo.ResultModel;
import com.free.front.bf.product.ProductCategoryBf;
import com.free.front.controller.BaseController;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

/**
 * <p>
 * 功能概述:
 * </p>
 * <p>
 * 功能详述:
 * </p>
 */
@Controller
public class productCatagoryController  extends BaseController {
    /*========================================================================*
     *                         Public Fields (公共属性)
     *========================================================================*/

    /*========================================================================*
     *                         Private Fields (私有属性)
     *========================================================================*/

    @Autowired
    private ProductCategoryBf categoryBf;

	@Value(value = "${sys.domain}")
    private String domain;

    /*========================================================================*
     *                         Construct Methods (构造方法)
     *========================================================================*/
	/**
	 * 产品种类
	 * 
	 * @param request
	 * @param partsId
	 * @return
	 */
	@RequestMapping("/prodCategory.htm")
	public String prodCategory(HttpServletRequest request, String partsId) {
		return getTempleate("/prod/prodCategory",request);
	}

	@RequestMapping("/partsCategoryInfos.json")
	@ResponseBody
	public ResultModel prodCategoryData(PartsCategoryVo condition){
		return ResultModel.success(categoryBf.selectListByConditionForFront(condition));
	}

	@RequestMapping("/partsCategoryInfosDirect.json")
	@ResponseBody
	public ResultModel prodCategoryDataOnly(PartsCategoryVo condition){
		return ResultModel.success(categoryBf.selectAllEnbaleCategorysDirect(condition));
	}

	@RequestMapping("/partsCategoryDetailInfo.json")
	@ResponseBody
	public ResultModel prodCategoryDetailInfo(Integer parsInfoid){
		return ResultModel.success(categoryBf.selectCatagoryDispInfo(parsInfoid));
	}
	
	/**
	 * 产品种类详情页面
	 * 
	 * @param request
	 * @param partsInfoId
	 * @param
	 * @return
	 */
	@RequestMapping("/prodCategoryDetail.htm")
	public ModelAndView prodCategoryDetail(HttpServletRequest request, Integer partsInfoId){
		String path = getTempleate("/prod/prodCategoryDetail",request);
		ModelAndView view = new ModelAndView(path);
		if(partsInfoId != null && partsInfoId >0){
			PartsInfoVedioVo vo = categoryBf.getVedio(partsInfoId);
			if(vo != null){
                view.addObject("vedioPath",domain + vo.getVedioUrl());
                view.addObject("vedioImg",domain + vo.getImageUrl());
            }else {
                view.addObject("vedioPath","");
                view.addObject("vedioImg","");
            }
		}else{
			view.addObject("vedioPath","");
			view.addObject("vedioImg","");
		}
		return view;
	}
	

	@RequestMapping("/prodCategorySec.htm")
	public String prodCategorySec(HttpServletRequest request){
		return getTempleate("/prod/prodCategorySec",request);
	}

	@RequestMapping("/prodSearchByCarType.htm")
	public String prodSearchByCarType(HttpServletRequest request){
		return getTempleate("/prod/prodSearchByCarType",request);
	}

	@RequestMapping("/prodSearchByPart.htm")
	public String prodSearchByPart(HttpServletRequest request){
		return getTempleate("/prod/prodSearchByPart",request);
	}
	
	@RequestMapping("/prodSearchByPrdArray.htm")
	public String prodSearchByPrdArray(HttpServletRequest request){
		return getTempleate("/prod/prodSearchByPrdArray",request);
	}

	
    /*========================================================================*
     *                         Public Methods (公有方法)
     *========================================================================*/

    /*========================================================================*
     *                         Private Methods (私有方法)
     *========================================================================*/
}
